import React from 'react'
import { Routes, Route, Navigate } from 'react-router-dom'
import { useUserStore } from './stores/user'
import Login from './views/Login.tsx'
import Main from './views/Main.tsx'
import './App.less'

const App: React.FC = () => {
  const { isLoggedIn } = useUserStore()
  console.log(isLoggedIn)
  return (
    <div className="app-container">
      <Routes>
        <Route 
          path="/login" 
          element={isLoggedIn ? <Navigate to="/dashboard" replace /> : <Login />} 
        />
        <Route 
          path="/*" 
          element={isLoggedIn ? <Main /> : <Navigate to="/login" replace />} 
        />
      </Routes>
    </div>
  )
}

export default App 